package com.wits.media;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhengboyuan on 2018-03-12.
 */

public class COsdOverlayMixer implements OsdOverlayMixer {

    protected List<OsdOverlayRender> renders = new ArrayList<>();

    @Override
    public boolean setOverlay(int index, OsdOverlay overlay) {
        if (index < 0 || index >= OsdOverlay.MAX_COUNT) {
            return false;
        }

        OsdOverlayRender render = new COsdOverlayRender();
        if (!render.open(overlay)) {
            return false;
        }

        renders.add(render);

        return true;
    }

    @Override
    public void clearOverlay() {
        renders.clear();
    }

    @Override
    public void draw(ImageFrame frame) {
        for (OsdOverlayRender render : renders) {
            render.draw(frame);
        }
    }

}
